home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / FILES.SWG / 0030_Create a TEMP filename.pas < prev    next >
Pascal/Delphi Source File  |  1993-09-26  |  1KB  |  30 lines

  1. {*****************************************************************************
  2.  * Function ...... TempFile()
  3.  * Purpose ....... To create a unique file name for use as a temporary work
  4.  *                 file
  5.  * Parameters .... Path       Location to create the file
  6.  * Returns ....... Name of temporary file
  7.  * Notes ......... Uses the functions Right, ItoS, Exist, and Empty
  8.  * Author ........ Martin Richardson
  9.  * Date .......... May 13, 1992
  10.  *****************************************************************************}
  11. FUNCTION TempFile( Path: STRING ): STRING;
  12. VAR 
  13.    DateStr  : DateTime;
  14.    Trash    : WORD;
  15.    Time     : LONGINT;
  16.    FileName : STRING;
  17. BEGIN
  18.      IF (NOT Empty( Path )) AND (Right( Path, 1 ) <> '\') THEN
  19.         Path := Path + '\';
  20.      REPEAT
  21.            WITH DateStr DO BEGIN
  22.                 GETDATE( Year, Month, Day, Trash );
  23.                 GETTIME( Hour, Min, Sec, Trash );
  24.            END;
  25.            PackTime( DateStr, Time );
  26.            FileName := Right( ItoS( Time, 0 ), 8 ) + '.$$$';
  27.      UNTIL NOT Exist( Path + FileName );
  28.      TempFile := Path + FileName;
  29. END;
  30.